<?php

// $Id$


require_once($WSC->get_site_inc_dir().'modules/admin_panel/site_admin_web_page_ua.class.php');

require_once($WSC->get_site_inc_dir().'modules/tree_menu/tree_menu_dbc.class.php');
require_once($WSC->get_site_inc_dir().'modules/admin_panel/classes/admin_user/admin_user_dbc.class.php');


class Index_WP extends Site_Admin_Web_Page_UA {
	public function init() {
		parent::init();

		$v = $this->create_view();
		$this->add_view($v);
	}


	public function run() {
		$need_change = false;
		if (file_exists($this->_config->get_scratch_dir().'change_admin_pwd')) {
			$need_change = $this->check_admin_password_needs_change();
		}

		if ($need_change) {
			$this->export('admin_pwd_needs_change', 1);
		}


		$exceptions_log_file = $this->_config->get_logs_dir().'exceptions.log';
		if (file_exists($exceptions_log_file)) {
			if (filesize($exceptions_log_file)) {
				$this->export('exception_log_not_empty', 1);
			}
		}


		$view = $this->get_view('default');

		return $view;
	}


	private function check_admin_password_needs_change() {
		$ret = false;

		$svm = $this->get_svm();
		$ua_config = $this->get_ua_config();
		$user = $svm->get_global_var($ua_config['session_var_name']);

		if ($user->get_username() == 'admin') {
			$password = $user->get_password();
			if (strlen($password) == 32) {
				$ret = true;
			}
		}

		return $ret;
	}
}


